package it.polimi.traveldream.web;

import it.polimi.traveldream.CustompackageDTO;
import it.polimi.traveldream.GestioneRicercaLocal;
import it.polimi.traveldream.HotelDTO;
import it.polimi.traveldream.TransportDTO;

import java.util.Map;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

@ManagedBean(name="infopackComprati")
@SessionScoped
public class InfoPackCompratiBean {
	
	@EJB
	private GestioneRicercaLocal gs;
	private CustompackageDTO packcustombyid;
	private HotelDTO hotelcustom;
	private TransportDTO voloandatacustom;
	private TransportDTO voloritornocustom;
	
	
    public String outcome(){
		 
		FacesContext fc = FacesContext.getCurrentInstance();
		
		System.out.print("djdjkjkd "+Integer.parseInt(getIdParam(fc)));
		
	    this.packcustombyid=gs.ricercaCustomPacchettoById(Integer.parseInt(getIdParam(fc)));
	    this.hotelcustom=gs.ricercaHotelDTOById(packcustombyid.getHotel());
	    this.voloandatacustom=gs.ricercaVoloDTOById(packcustombyid.getVoloandata());
	    this.voloritornocustom=gs.ricercaVoloDTOById(packcustombyid.getVoloritorno());
	    	    
        return "/users/infoPacchettiComprati.xhtml?faces-redirect=true";
	  }
 

	private String getIdParam(FacesContext fc){
        String s;
	    Map<String,String> params = fc.getExternalContext().getRequestParameterMap();
	    s=params.get("action");
        System.out.print("parametro ricevuto "+s);
	    return s;
	}



	public CustompackageDTO getPackcustombyid() {
		return packcustombyid;
	}


	public void setPackcustombyid(CustompackageDTO packacustombyid) {
		this.packcustombyid = packacustombyid;
	}


	public HotelDTO getHotelcustom() {
		return hotelcustom;
	}


	public void setHotelcustom(HotelDTO hotelcustom) {
		this.hotelcustom = hotelcustom;
	}


	public TransportDTO getVoloandatacustom() {
		return voloandatacustom;
	}


	public void setVoloandatacustom(TransportDTO voloandatacustom) {
		this.voloandatacustom = voloandatacustom;
	}


	public TransportDTO getVoloritornocustom() {
		return voloritornocustom;
	}


	public void setVoloritornocustom(TransportDTO voloritornocustom) {
		this.voloritornocustom = voloritornocustom;
	}
 	

}
